<?php

class GpropertyModeL extends Model{

	public $table='gproperty';
	
	public function add_data($data=null){
		
		return $this->add($data);
	}
	
	public function get_all_data($where=null){
		
		return $this->where($where)->all();
	}
	
	public function update_data($where=null){
		
		$this->where($where)->delete();
		$arr=array();
		$gpvalue= Q('post.gpvalue');
		$aprice=Q('post.aprice');
		$tpid=Q('post.tpid');
		if(isset($tpid)){
			foreach ($tpid as $k => $v) {
				$arr=array(
					'gid'=>Q('get.gid'),
					'tpid'=>$v,
					'gpvalue'=>$gpvalue[$k],
					'aprice'=>$aprice[$k],
				);
				$this->add_data($arr);
			}
		}
		return TRUE;
	}
	
	public function del_data($where){
		return $this->where($where)->delete();
	}
	
	public function get_gpvalue($where=null){
		
		return $this->where($where)->getField('gpvalue',true);
	}
}
